import { RiskControlRule } from '@shared/interfaces/risk-control'
import { Validators, FormGroup, FormBuilder } from '@angular/forms'
import { RiskRuleStoreService } from './rule-store.service'

export abstract class RiskControlRuleNewBaseClass {
  riskControlRule: RiskControlRule

  validateForm: FormGroup

  constructor(
    public fb: FormBuilder,
    public riskRuleStore: RiskRuleStoreService,
  ) {
    this.validateForm = this.fb.group({})
    this.initData()
  }

  initData(): void {
    this.riskRuleStore
      .value$
      .subscribe(riskControlRule => this.riskControlRule = riskControlRule)
  }

  checkValid(): boolean {
    this.pushDataToStore()
    return true
  }

  abstract pushDataToStore(): void

}
